import '../index.dart';

class CommonSelect extends BaseUpDownWidget {
  final String? content;
  final String? placeholder;
  final GestureTapCallback? onTap;

  CommonSelect(
      {Key? key,
      this.content,
      this.placeholder,
      this.onTap,
      required title,
      isHideDivide = false,
      isRequired = false})
      : super(
            key: key,
            title: title,
            isHideDivide: isHideDivide,
            isRequired: isRequired);

  @override
  Widget build(BuildContext context) {
    List<Widget> children = <Widget>[];
    //标题
    if (content != null && content!.isNotEmpty) {
      children.add(Expanded(
        child: Text(
          content!,
          textAlign: TextAlign.left,
          style: Theme.of(context).textTheme.titleMedium,
        ),
      ));
    } else {
      children.add(Expanded(
        child: Text(
          placeholder ?? "请选择",
          textAlign: TextAlign.left,
          style: Theme.of(context)
              .textTheme
              .titleMedium
              ?.copyWith(color: Colors.grey),
        ),
      ));
    }

    children.add(const Icon(
      Icons.chevron_right,
      color: Colors.grey,
    ));

    setDownWidget(
      Container(
          padding: const EdgeInsets.only(top: 10, bottom: 10),
          child: Row(
            children: children,
          )),
    );
    return InkWell(
      child: super.build(context),
      onTap: onTap,
    );
  }
}
